<template>
  <div class="buttongroup" :style="`top:${position.top}px;left:${position.left}px;display:${visible?'flex':'none'};`">
    <div v-for="(item, index) in menuList" :key="index" @click="callMenuListFunction(index)">{{item.name}}</div>
  </div>
</template>

<script>
export default {
  props: {
    menuList: { // {function, name}
      type: Array, default: ()=>[], require: true
    },
    position: {
      type: Object, default: ()=>null, require: true
    },
    visible: {
      type: Boolean, default: ()=>false, require: true
    },
  },
  methods: {
    callMenuListFunction(index){
      this.menuList[index].function()
    }
  }
}
</script>

<style>
.buttongroup{
  display: flex; justify-content: center; align-content: center; flex-direction: column;
  padding: 4px; z-index:999;
  width: 100px; height: auto;
  position:absolute;
  background: #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 0 6px rgba(0, 0, 0, .1);
}
.buttongroup div:last-child{
  border-bottom: 0px solid rgb(117, 117, 117);
}
.buttongroup div{
  list-style-type: none;
  margin: 0;
  padding: 0;
  height: 30px;
  font-size: 15px;
  color: #555;
  line-height: 30px;
  margin: 0px 5px 0px 5px;
  box-sizing: border-box;
  position: relative;
  font-weight: 400;
  border-bottom: 1px solid rgb(228, 228, 228);
}
</style>